package com.yl.auth.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yl.auth.entity.XinzifuliBean;
import com.yl.auth.mapper.YuangongMapper;
import com.yl.auth.model.entity.Yuangong;
import com.yl.auth.service.XinzifuliService;
import com.yl.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author 王帅洋
 * @datetime 2023/6/28 15:58
 * @description 类对象
 */
@Api(tags = "薪资福利")
@RestController
@RequestMapping("/admin/caiwushouzhi/xinzifuli")
public class XinzifuliController {
    @Resource
    private XinzifuliService xinzifuliService;
    @Resource
    private YuangongMapper yuangong;

    @ApiOperation("分页+全查")
    @GetMapping("/{page}/{limit}")
    public Result selectPage(
            @PathVariable Long page,
            @PathVariable Long limit,
            XinzifuliBean xinzifuliBean
    ) {
        Page<XinzifuliBean> pageParam = new Page<>(page, limit);
        IPage<XinzifuliBean> page1 = xinzifuliService.findAll(pageParam, xinzifuliBean);
        return Result.ok(page1);
    }

//    @GetMapping("/getById/{id}")
//    public Result getById(@PathVariable Long id) {
//        XinzifuliBean xinzifuliBean = xinzifuliService.getById(id);
//        return Result.ok(xinzifuliBean);
//    }

    @ApiOperation("根据id查询")
    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable Long id) {
        XinzifuliBean xinzifuliBean = xinzifuliService.getByid(id);
        return Result.ok(xinzifuliBean);
    }
    @ApiOperation("修改")
    @PutMapping("/updateById")
    public Result update(@RequestBody XinzifuliBean xinzifuliBean) {
        xinzifuliBean.setJifen("0");
        xinzifuliService.updateById(xinzifuliBean);
        return Result.ok();
    }
    @ApiOperation("根据id修改")
    @PutMapping("/update/{id}")
    public Result update(@PathVariable Integer id){
        xinzifuliService.updatexinzi(id);
        return Result.ok();
    }

}
